﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HZ.Supervise.Web.DataReport
{
    public partial class AreaShiPSLList : System.Web.UI.Page
    {
        string Area = "";
        string source = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            BindData();
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_chaxun_Click(object sender, EventArgs e)
        {
            BindData();
        }
        /// <summary>
        /// 查询方法
        /// modify by张雄   2011.5.4
        /// </summary>
        public void BindData()
        {
            //查询条件按照下拉框条件
            string orderby = this.OrderFileds.SelectedItem.Value + "  " + this.OrderType.SelectedItem.Value;
            if (dropArea.SelectedValue != "全部")    //判断是否等于‘全部’  ‘是’不加条件‘否’加入采购类型的查询条件
            {
                Area = this.dropArea.SelectedValue;
            }
            if (dropsource.SelectedValue!="全部")
            {
                source = this.dropsource.SelectedValue;
            }
            HZ.Supervise.IBLL.IExecuteContext iEC = HZ.Supervise.BLLFactory.ExecuteContext();
            System.Data.DataTable dt = iEC.getAreaSHIlIST(orderby, Area,source);
            this.gvwPSLInfo.DataSource = dt;
            HZ.Supervise.Web.Function.ChangeRate_PS(dt, "DistributeRate");
            HZ.Supervise.Web.Function.AddColumn(dt, "WareHouseRate", "SortSource");
            this.gvwPSLInfo.DataBind();
        }
        /// <summary>
        /// 导出
        /// create by 张雄  2011.5.5
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnExcel_Click(object sender, EventArgs e)
        {
            string orderby = this.OrderFileds.SelectedValue + " " + this.OrderType.SelectedValue;   //取得排序条件的值
            if (dropArea.SelectedValue != "全部")    //判断是否等于‘全部’  ‘是’不加条件‘否’加入采购类型的查询条件
            {
                Area = this.dropArea.SelectedValue;
            }
            if (dropsource.SelectedValue!="全部")
            {
                source = this.dropsource.SelectedValue;
            }
            HZ.Supervise.IBLL.IExecuteContext iEC = HZ.Supervise.BLLFactory.ExecuteContext();
            System.Data.DataTable dt = iEC.getAreaSHIlIST(orderby,Area,source);
            HZ.Supervise.Web.Function.ChangeRate_PS(dt, "DistributeRate");
            HZ.Supervise.Web.Function.AddColumn(dt, "WareHouseRate", "SortSource");
            ExportFile.Instance.ExportData(dt, gvwPSLInfo, this.Page);
        }
    }
}
